import { CategoryModelState } from '@/models/category';
import { ICategory } from '@/types';
import { useEffect } from 'react'
import { useDispatch, useSelector } from 'umi'
import style from "./index.less"

export default function Articlecategory() {
    const dispatch = useDispatch();
    const { archivesPage } = useSelector((state: { category: CategoryModelState }) => ({ ...state.category }))

    //发起请求
    useEffect(() => {
        dispatch({
            type: 'category/getCategory'
        })
    }, [])
    return (
        <div>
            <div className={style.flet_title}>
                <span>文章分类</span>
            </div>
            <ul className={style.fileclassi}>
                {archivesPage.map((item: ICategory) => {
                    return <li key={item.id}>
                        <a>
                            <span>{item.label}</span>
                            <span> <span>共计 {item.articleCount} 篇文章</span></span>
                        </a>
                    </li>
                })}
            </ul>
        </div>
    )
}
